package com.cskaoyan.controller;

import com.cskaoyan.service.stat.StatService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.stat.StatGoodsVo;
import com.cskaoyan.vo.stat.StatOrderVo;
import com.cskaoyan.vo.stat.StatUserVo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description:统计报表模块的controller层，主要功能有
 * stat/user
 * stat/order
 * stat/goods
 * author:houzhitao@139.com
 */
@RestController
@RequestMapping("admin/stat")
public class StatController {
   private ObjectMapper objectMapper= new ObjectMapper();
    {
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    }

    @Autowired
    StatService statService;

    @RequestMapping("user")
    @RequiresPermissions("admin:stat:user")
    public BaseRespVo statUser(){
        StatUserVo statUserVo = statService.statUser();
        return BaseRespVo.ok(statUserVo);
    }

    @RequestMapping("order")
    @RequiresPermissions("admin:stat:order")
    public BaseRespVo statOrder(){
        StatOrderVo statOrderVo = statService.statOrder();
        return BaseRespVo.ok(statOrderVo);
    }

    @RequestMapping("goods")
    @RequiresPermissions("admin:stat:goods")
    public BaseRespVo statGoods(){
        StatGoodsVo statGoodsVo = statService.statGoods();
        return BaseRespVo.ok(statGoodsVo);
    }

}
